{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1. NumPy是Python科学计算库，用于处理任意维度的数组"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2. NumPy提供了N维数组数据结构ndarray"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3. ndarray支持向量化运算"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4. NunPy是使用C语言编写的，速度快"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5. ndarray的属性"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "属性 | 描述\n",
    "-----|-----\n",
    "shape|数组的形状\n",
    "ndim |数组的维度\n",
    "size |数组的元素数量\n",
    "itemsize|一个元素占用的字节数\n",
    "dtype  |元素的类型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "6. 编程练习属性操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a的形状：(3,)\n",
      "b的形状：(2, 3)\n",
      "c的形状：(2, 2, 2)\n",
      "a的维度：1\n",
      "b的维度：2\n",
      "c的维度：3\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "# 创建一维数组\n",
    "a = np.array([1, 2, 3], dtype=np.int32)\n",
    "# 创建二维数组\n",
    "b = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float64)\n",
    "# 创建三维数组\n",
    "c = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])\n",
    "\n",
    "print(f\"a的形状：{a.shape}\")\n",
    "print(f\"b的形状：{b.shape}\")\n",
    "print(f\"c的形状：{c.shape}\")\n",
    "\n",
    "print(f\"a的维度：{a.ndim}\")\n",
    "print(f\"b的维度：{b.ndim}\")\n",
    "print(f\"c的维度：{c.ndim}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 随堂练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 编写代码"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
